const Project = require("./modules/projectModule");

//添加项目
const addPorject = async (info) => {
  await Project.create(info);
  const data = await Project.findAll();
  return JSON.parse(JSON.stringify(data));
};

//修改项目
const updateProject = async (id, info) => {
  await Project.update(info, {
    where: {
      id,
    },
  });
  const data = await Project.findAll();
  return JSON.parse(JSON.stringify(data));
};

//删除项目
const deleteProject = async (id) => {
  await Project.destroy({ where: { id } });
  return true;
};

//获取项目
const getProject = async () => {
  const data = await Project.findAll();
  return JSON.parse(JSON.stringify(data));
};

module.exports = {
  addPorject,
  updateProject,
  deleteProject,
  getProject,
};
